# Replication Code: Can (Thin) Populism be manipulated without manipulating Host Ideology? Evidence from a conjoint validation approach
# Script 04: Conjoint Data Cleaning

# Ensure packages from script_01 are loaded
# Requires Prolific_US_Raw.csv and Prolific_UK_Raw.csv to be in working directory


#####################################################
# Sample 1: US Study with No Partisan Attribute Shown
#####################################################

# Note: See information on "Partisan" conjoint attribute in ReadMe file
# Attribute was only displayed to respondents in Sample 2

# DV 1: "Say that politicians should always listen to the people"

# Binary DV 1: "Say that politicians should always listen to the people"

# Import "Long" Format Conjoint Data
s1_conjoint_listen <- read.qualtrics('Prolific_US_Raw.csv', responses = c("s1_pair1_choice_1","s1_pair2_choice_1","s1_pair3_choice_1","s1_pair4_choice_1","s1_pair5_choice_1", "s1_pair6_choice_1"), covariates = c("Finished","Sample"), respondentID = "ResponseId", new.format = TRUE)
s1_conjoint_listen <- s1_conjoint_listen[!is.na(s1_conjoint_listen["selected"]),]
s1_conjoint_listen <- s1_conjoint_listen[(s1_conjoint_listen$Finished==1),]

# Relabeling Partisanship levels as not shown to respondents (see ReadMe)
table(s1_conjoint_listen$Partisanship)
s1_conjoint_listen$Partisanship = "Not shown"

# Relabeling Conjoint Attributes
table(s1_conjoint_listen$`Anti-elitism`)
levels(s1_conjoint_listen$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington insiders")
table(s1_conjoint_listen$`People-centrism`)
levels(s1_conjoint_listen$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "American people", "The people")
table(s1_conjoint_listen$Filler)
levels(s1_conjoint_listen$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")


# Rating DV 1: "Say that politicians should always listen to the people"

# Import "Long" Format Conjoint Data
s1_conjoint_listen_ranks <- read.qualtrics('Prolific_US_Raw.csv', ranks = c("s1_pair1_people_1", "s1_pair1_people_2", "s1_pair2_people_1", "s1_pair2_people_2", "s1_pair3_people_1", "s1_pair3_people_2", "s1_pair4_people_1", "s1_pair4_people_2", "s1_pair5_people_1", "s1_pair5_people_2", "s1_pair6_people_1", "s1_pair6_people_2"), covariates = c("Finished", "Sample"), respondentID = "ResponseId", new.format = TRUE)
s1_conjoint_listen_ranks <- s1_conjoint_listen_ranks[!is.na(s1_conjoint_listen_ranks["selected"]),]
s1_conjoint_listen_ranks <- s1_conjoint_listen_ranks[(s1_conjoint_listen_ranks$Finished==1),]

# Relabeling Partisanship levels as not shown to respondents (see ReadMe)
table(s1_conjoint_listen_ranks$Partisanship)
s1_conjoint_listen_ranks$Partisanship = "Not shown"

# Relabeling Conjoint Attributes
table(s1_conjoint_listen_ranks$`Anti-elitism`)
levels(s1_conjoint_listen_ranks$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington insiders")
table(s1_conjoint_listen_ranks$`People-centrism`)
levels(s1_conjoint_listen_ranks$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "American people", "The people")
table(s1_conjoint_listen_ranks$Filler)
levels(s1_conjoint_listen_ranks$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")


# DV 2: "Say that many people in the political class are crooked"

# Binary DV 2: "Say that many people in the political class are crooked"

# Import "Long" Format Conjoint Data
s1_conjoint_crooked <- read.qualtrics('Prolific_US_Raw.csv', responses = c("s1_pair1_choice_2","s1_pair2_choice_2","s1_pair3_choice_2","s1_pair4_choice_2","s1_pair5_choice_2", "s1_pair6_choice_2"), covariates = c("Finished", "Sample"), respondentID = "ResponseId", new.format = TRUE)
s1_conjoint_crooked <- s1_conjoint_crooked[!is.na(s1_conjoint_crooked["selected"]),]
s1_conjoint_crooked <- s1_conjoint_crooked[(s1_conjoint_crooked$Finished==1),]

# Relabeling Partisanship levels as not shown to respondents (see ReadMe)
table(s1_conjoint_crooked$Partisanship)
s1_conjoint_crooked$Partisanship = "Not shown"

# Relabeling Conjoint Attributes
table(s1_conjoint_crooked$`Anti-elitism`)
levels(s1_conjoint_crooked$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington insiders")
table(s1_conjoint_crooked$`People-centrism`)
levels(s1_conjoint_crooked$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "American people", "The people")
table(s1_conjoint_crooked$Filler)
levels(s1_conjoint_crooked$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")


# Rating DV 2: "Say that many people in the political class are crooked"

# Import "Long" Format Conjoint Data
s1_conjoint_crooked_ranks <- read.qualtrics('Prolific_US_Raw.csv', ranks = c("s1_pair1_elite_1", "s1_pair1_elite_2", "s1_pair2_elite_1", "s1_pair2_elite_2", "s1_pair3_elite_1", "s1_pair3_elite_2", "s1_pair4_elite_1", "s1_pair4_elite_2", "s1_pair5_elite_1", "s1_pair5_elite_2", "s1_pair6_elite_1", "s1_pair6_elite_2"), covariates = c("Finished", "Sample"), respondentID = "ResponseId", new.format = TRUE)
s1_conjoint_crooked_ranks <- s1_conjoint_crooked_ranks[!is.na(s1_conjoint_crooked_ranks["selected"]),]
s1_conjoint_crooked_ranks <- s1_conjoint_crooked_ranks[(s1_conjoint_crooked_ranks$Finished==1),]


# Relabeling Partisanship levels as not shown to respondents (see ReadMe)
table(s1_conjoint_crooked_ranks$Partisanship)
s1_conjoint_crooked_ranks$Partisanship = "Not shown"

# Relabeling Conjoint Attributes
table(s1_conjoint_crooked_ranks$`Anti-elitism`)
levels(s1_conjoint_crooked_ranks$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington insiders")
table(s1_conjoint_crooked_ranks$`People-centrism`)
levels(s1_conjoint_crooked_ranks$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "American people", "The people")
table(s1_conjoint_crooked_ranks$Filler)
levels(s1_conjoint_crooked_ranks$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")


# DV 3: "Say that immigration should be reduced"

# Binary DV 3: "Say that immigration should be reduced"

# Import "Long" Format Conjoint Data
s1_conjoint_immig <- read.qualtrics('Prolific_US_Raw.csv', responses = c("s1_pair1_choice_3","s1_pair2_choice_3","s1_pair3_choice_3","s1_pair4_choice_3","s1_pair5_choice_3", "s1_pair6_choice_3"), covariates = c("Finished", "Sample"), respondentID = "ResponseId", new.format = TRUE)
s1_conjoint_immig <- s1_conjoint_immig[!is.na(s1_conjoint_immig["selected"]),]
s1_conjoint_immig <- s1_conjoint_immig[(s1_conjoint_immig$Finished==1),]

# Relabeling Partisanship levels as not shown to respondents (see ReadMe)
table(s1_conjoint_immig$Partisanship)
s1_conjoint_immig$Partisanship = "Not shown"

# Relabeling Conjoint Attributes
table(s1_conjoint_immig$`Anti-elitism`)
levels(s1_conjoint_immig$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington insiders")
table(s1_conjoint_immig$`People-centrism`)
levels(s1_conjoint_immig$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "American people", "The people")
table(s1_conjoint_immig$Filler)
levels(s1_conjoint_immig$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")

# Reorder Factor Levels for H2 AMCES
s1_conjoint_immig_b <- s1_conjoint_immig
s1_conjoint_immig_b$`Anti-elitism` <- factor(s1_conjoint_immig_b$`Anti-elitism`, levels=c("Corrupt elite", "Washington insiders", "Out-of-touch bureaucrats", "Control: No anti-elitism statement"))
s1_conjoint_immig_b$`People-centrism` <- factor(s1_conjoint_immig_b$`People-centrism`, levels=c("The people", "American people", "Honest, hardworking citizens", "Control: No people-centrism statement"))


# Rating DV 3: "Say that immigration should be reduced"

# Import "Long" Format Conjoint Data
s1_conjoint_immig_ranks <- read.qualtrics('Prolific_US_Raw.csv', ranks = c("s1_pair1_immigration_1", "s1_pair1_immigration_2", "s1_pair2_immigration_1", "s1_pair2_immigration_2", "s1_pair3_immigration_1", "s1_pair3_immigration_2", "s1_pair4_immigration_1", "s1_pair4_immigration_2", "s1_pair5_immigration_1", "s1_pair5_immigration_2", "s1_pair6_immigration_1", "s1_pair6_immigration_2"), covariates = c("Finished", "Sample"), respondentID = "ResponseId", new.format = TRUE)
s1_conjoint_immig_ranks <- s1_conjoint_immig_ranks[!is.na(s1_conjoint_immig_ranks["selected"]),]
s1_conjoint_immig_ranks <- s1_conjoint_immig_ranks[(s1_conjoint_immig_ranks$Finished==1),]

# Relabeling Partisanship levels as not shown to respondents (see ReadMe)
table(s1_conjoint_immig_ranks$Partisanship)
s1_conjoint_immig_ranks$Partisanship = "Not shown"

# Relabeling Conjoint Attributes
table(s1_conjoint_immig_ranks$`Anti-elitism`)
levels(s1_conjoint_immig_ranks$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington insiders")
table(s1_conjoint_immig_ranks$`People-centrism`)
levels(s1_conjoint_immig_ranks$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "American people", "The people")
table(s1_conjoint_immig_ranks$Filler)
levels(s1_conjoint_immig_ranks$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")

# Reorder Factor Levels for H2 AMCES
s1_conjoint_immig_ranks_b <- s1_conjoint_immig_ranks
s1_conjoint_immig_ranks_b$`Anti-elitism` <- factor(s1_conjoint_immig_ranks_b$`Anti-elitism`, levels=c("Corrupt elite", "Washington insiders", "Out-of-touch bureaucrats", "Control: No anti-elitism statement"))
s1_conjoint_immig_ranks_b$`People-centrism` <- factor(s1_conjoint_immig_ranks_b$`People-centrism`, levels=c("The people", "American people", "Honest, hardworking citizens", "Control: No people-centrism statement"))


# DV 4: "Have conservative ideology"

# Binary DV 4: "Have conservative ideology"

# Import "Long" Format Conjoint Data
s1_conjoint_cons <- read.qualtrics('Prolific_US_Raw.csv', responses = c("s1_pair1_choice_4","s1_pair2_choice_4","s1_pair3_choice_4","s1_pair4_choice_4","s1_pair5_choice_4", "s1_pair6_choice_4"), covariates = c("Finished", "Sample"), respondentID = "ResponseId", new.format = TRUE)
s1_conjoint_cons <- s1_conjoint_cons[!is.na(s1_conjoint_cons["selected"]),]
s1_conjoint_cons <- s1_conjoint_cons[(s1_conjoint_cons$Finished==1),]

# Relabeling Partisanship levels as not shown to respondents (see ReadMe)
table(s1_conjoint_cons$Partisanship)
s1_conjoint_cons$Partisanship = "Not shown"

# Relabeling Conjoint Attributes
table(s1_conjoint_cons$`Anti-elitism`)
levels(s1_conjoint_cons$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington insiders")
table(s1_conjoint_cons$`People-centrism`)
levels(s1_conjoint_cons$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "American people", "The people")
table(s1_conjoint_cons$Filler)
levels(s1_conjoint_cons$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")

# Reorder Factor Levels for H2 AMCES
s1_conjoint_cons_b <- s1_conjoint_cons
s1_conjoint_cons_b$`Anti-elitism` <- factor(s1_conjoint_cons_b$`Anti-elitism`, levels=c("Corrupt elite", "Washington insiders", "Out-of-touch bureaucrats", "Control: No anti-elitism statement"))
s1_conjoint_cons_b$`People-centrism` <- factor(s1_conjoint_cons_b$`People-centrism`, levels=c("The people", "American people", "Honest, hardworking citizens", "Control: No people-centrism statement"))


# Rating DV 4: "Have conservative ideology"

# Import "Long" Format Conjoint Data
s1_conjoint_cons_ranks <- read.qualtrics('Prolific_US_Raw.csv', ranks = c("s1_pair1_ideology_1", "s1_pair1_ideology_2", "s1_pair2_ideology_1", "s1_pair2_ideology_2", "s1_pair3_ideology_1", "s1_pair3_ideology_2", "s1_pair4_ideology_1", "s1_pair4_ideology_2", "s1_pair5_ideology_1", "s1_pair5_ideology_2", "s1_pair6_ideology_1", "s1_pair6_ideology_2"), covariates = c("Finished", "Sample"), respondentID = "ResponseId", new.format = TRUE)
s1_conjoint_cons_ranks <- s1_conjoint_cons_ranks[!is.na(s1_conjoint_cons_ranks["selected"]),]
s1_conjoint_cons_ranks <- s1_conjoint_cons_ranks[(s1_conjoint_cons_ranks$Finished==1),]

# Relabeling Partisanship levels as not shown to respondents (see ReadMe)
table(s1_conjoint_cons_ranks$Partisanship)
s1_conjoint_cons_ranks$Partisanship = "Not shown"

# Relabeling Conjoint Attributes
table(s1_conjoint_cons_ranks$`Anti-elitism`)
levels(s1_conjoint_cons_ranks$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington insiders")
table(s1_conjoint_cons_ranks$`People-centrism`)
levels(s1_conjoint_cons_ranks$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "American people", "The people")
table(s1_conjoint_cons_ranks$Filler)
levels(s1_conjoint_cons_ranks$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")

# Reorder Factor Levels for H2 AMCES
s1_conjoint_cons_ranks_b <- s1_conjoint_cons_ranks
s1_conjoint_cons_ranks_b$`Anti-elitism` <- factor(s1_conjoint_cons_ranks_b$`Anti-elitism`, levels=c("Corrupt elite", "Washington insiders", "Out-of-touch bureaucrats", "Control: No anti-elitism statement"))
s1_conjoint_cons_ranks_b$`People-centrism` <- factor(s1_conjoint_cons_ranks_b$`People-centrism`, levels=c("The people", "American people", "Honest, hardworking citizens", "Control: No people-centrism statement"))



#####################################################
# Sample 2: US Study with Partisan Attribute Shown
#####################################################

# DV 1: "Say that politicians should always listen to the people"

# Binary DV 1: "Say that politicians should always listen to the people"

# Import "Long" Format Conjoint Data
s2_conjoint_listen <- read.qualtrics('Prolific_US_Raw.csv', responses = c("s2_pair1_choice_1","s2_pair2_choice_1","s2_pair3_choice_1","s2_pair4_choice_1","s2_pair5_choice_1", "s2_pair6_choice_1"), covariates = c("Finished", "Sample"), respondentID = "ResponseId", new.format = TRUE)
s2_conjoint_listen <- s2_conjoint_listen[!is.na(s2_conjoint_listen["selected"]),]
s2_conjoint_listen <- s2_conjoint_listen[(s2_conjoint_listen$Finished==1),]

# Relabeling Conjoint Attributes
table(s2_conjoint_listen$`Anti-elitism`)
levels(s2_conjoint_listen$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington insiders")
table(s2_conjoint_listen$`People-centrism`)
levels(s2_conjoint_listen$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "American people", "The people")
table(s2_conjoint_listen$Filler)
levels(s2_conjoint_listen$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")


# Rating DV 1: "Say that politicians should always listen to the people"

# Import "Long" Format Conjoint Data
s2_conjoint_listen_ranks <- read.qualtrics('Prolific_US_Raw.csv', ranks = c("s2_pair1_people_1", "s2_pair1_people_2", "s2_pair2_people_1", "s2_pair2_people_2", "s2_pair3_people_1", "s2_pair3_people_2", "s2_pair4_people_1", "s2_pair4_people_2", "s2_pair5_people_1", "s2_pair5_people_2", "s2_pair6_people_1", "s2_pair6_people_2"), covariates = c("Finished", "Sample"), respondentID = "ResponseId", new.format = TRUE)
s2_conjoint_listen_ranks <- s2_conjoint_listen_ranks[!is.na(s2_conjoint_listen_ranks["selected"]),]
s2_conjoint_listen_ranks <- s2_conjoint_listen_ranks[(s2_conjoint_listen_ranks$Finished==1),]

# Relabeling Conjoint Attributes
table(s2_conjoint_listen_ranks$`Anti-elitism`)
levels(s2_conjoint_listen_ranks$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington insiders")
table(s2_conjoint_listen_ranks$`People-centrism`)
levels(s2_conjoint_listen_ranks$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "American people", "The people")
table(s2_conjoint_listen_ranks$Filler)
levels(s2_conjoint_listen_ranks$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")





# DV 2: "Say that many people in the political class are crooked"

# Binary DV 2: "Say that many people in the political class are crooked"

# Import "Long" Format Conjoint Data
s2_conjoint_crooked <- read.qualtrics('Prolific_US_Raw.csv', responses = c("s2_pair1_choice_2","s2_pair2_choice_2","s2_pair3_choice_2","s2_pair4_choice_2","s2_pair5_choice_2", "s2_pair6_choice_2"), covariates = c("Finished", "Sample"), respondentID = "ResponseId", new.format = TRUE)
s2_conjoint_crooked <- s2_conjoint_crooked[!is.na(s2_conjoint_crooked["selected"]),]
s2_conjoint_crooked <- s2_conjoint_crooked[(s2_conjoint_crooked$Finished==1),]

# Relabeling Conjoint Attributes
table(s2_conjoint_crooked$`Anti-elitism`)
levels(s2_conjoint_crooked$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington insiders")
table(s2_conjoint_crooked$`People-centrism`)
levels(s2_conjoint_crooked$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "American people", "The people")
table(s2_conjoint_crooked$Filler)
levels(s2_conjoint_crooked$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")


# Rating DV 2: "Say that many people in the political class are crooked"

# Import "Long" Format Conjoint Data
s2_conjoint_crooked_ranks <- read.qualtrics('Prolific_US_Raw.csv', ranks = c("s2_pair1_elite_1", "s2_pair1_elite_2", "s2_pair2_elite_1", "s2_pair2_elite_2", "s2_pair3_elite_1", "s2_pair3_elite_2", "s2_pair4_elite_1", "s2_pair4_elite_2", "s2_pair5_elite_1", "s2_pair5_elite_2", "s2_pair6_elite_1", "s2_pair6_elite_2"), covariates = c("Finished", "Sample"), respondentID = "ResponseId", new.format = TRUE)
s2_conjoint_crooked_ranks <- s2_conjoint_crooked_ranks[!is.na(s2_conjoint_crooked_ranks["selected"]),]
s2_conjoint_crooked_ranks <- s2_conjoint_crooked_ranks[(s2_conjoint_crooked_ranks$Finished==1),]

# Relabeling Conjoint Attributes
table(s2_conjoint_crooked_ranks$`Anti-elitism`)
levels(s2_conjoint_crooked_ranks$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington insiders")
table(s2_conjoint_crooked_ranks$`People-centrism`)
levels(s2_conjoint_crooked_ranks$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "American people", "The people")
table(s2_conjoint_crooked_ranks$Filler)
levels(s2_conjoint_crooked_ranks$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")



# DV 3: "Say that immigration should be reduced"

# Binary DV 3: "Say that immigration should be reduced"

# Import "Long" Format Conjoint Data
s2_conjoint_immig <- read.qualtrics('Prolific_US_Raw.csv', responses = c("s2_pair1_choice_3","s2_pair2_choice_3","s2_pair3_choice_3","s2_pair4_choice_3","s2_pair5_choice_3", "s2_pair6_choice_3"), covariates = c("Finished", "Sample"), respondentID = "ResponseId", new.format = TRUE)
s2_conjoint_immig <- s2_conjoint_immig[!is.na(s2_conjoint_immig["selected"]),]
s2_conjoint_immig <- s2_conjoint_immig[(s2_conjoint_immig$Finished==1),]

# Relabeling Conjoint Attributes
table(s2_conjoint_immig$`Anti-elitism`)
levels(s2_conjoint_immig$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington insiders")
table(s2_conjoint_immig$`People-centrism`)
levels(s2_conjoint_immig$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "American people", "The people")
table(s2_conjoint_immig$Filler)
levels(s2_conjoint_immig$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")

# Reorder Factor Levels for H2 AMCES
s2_conjoint_immig_b <- s2_conjoint_immig
s2_conjoint_immig_b$`Anti-elitism` <- factor(s2_conjoint_immig_b$`Anti-elitism`, levels=c("Corrupt elite", "Washington insiders", "Out-of-touch bureaucrats", "Control: No anti-elitism statement"))
s2_conjoint_immig_b$`People-centrism` <- factor(s2_conjoint_immig_b$`People-centrism`, levels=c("The people", "American people", "Honest, hardworking citizens", "Control: No people-centrism statement"))




# Rating DV 3: "Say that immigration should be reduced"

# Import "Long" Format Conjoint Data
s2_conjoint_immig_ranks <- read.qualtrics('Prolific_US_Raw.csv', ranks = c("s2_pair1_immigration_1", "s2_pair1_immigration_2", "s2_pair2_immigration_1", "s2_pair2_immigration_2", "s2_pair3_immigration_1", "s2_pair3_immigration_2", "s2_pair4_immigration_1", "s2_pair4_immigration_2", "s2_pair5_immigration_1", "s2_pair5_immigration_2", "s2_pair6_immigration_1", "s2_pair6_immigration_2"), covariates = c("Finished", "Sample"), respondentID = "ResponseId", new.format = TRUE)
s2_conjoint_immig_ranks <- s2_conjoint_immig_ranks[!is.na(s2_conjoint_immig_ranks["selected"]),]
s2_conjoint_immig_ranks <- s2_conjoint_immig_ranks[(s2_conjoint_immig_ranks$Finished==1),]

# Relabeling Conjoint Attributes
table(s2_conjoint_immig_ranks$`Anti-elitism`)
levels(s2_conjoint_immig_ranks$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington insiders")
table(s2_conjoint_immig_ranks$`People-centrism`)
levels(s2_conjoint_immig_ranks$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "American people", "The people")
table(s2_conjoint_immig_ranks$Filler)
levels(s2_conjoint_immig_ranks$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")

# Reorder Factor Levels for H2 AMCES
s2_conjoint_immig_ranks_b <- s2_conjoint_immig_ranks
s2_conjoint_immig_ranks_b$`Anti-elitism` <- factor(s2_conjoint_immig_ranks_b$`Anti-elitism`, levels=c("Corrupt elite", "Washington insiders", "Out-of-touch bureaucrats", "Control: No anti-elitism statement"))
s2_conjoint_immig_ranks_b$`People-centrism` <- factor(s2_conjoint_immig_ranks_b$`People-centrism`, levels=c("The people", "American people", "Honest, hardworking citizens", "Control: No people-centrism statement"))



# DV 4: "Have conservative ideology"

# Binary DV 4: "Have conservative ideology"

# Import "Long" Format Conjoint Data
s2_conjoint_cons <- read.qualtrics('Prolific_US_Raw.csv', responses = c("s2_pair1_choice_4","s2_pair2_choice_4","s2_pair3_choice_4","s2_pair4_choice_4","s2_pair5_choice_4", "s2_pair6_choice_4"), covariates = c("Finished", "Sample"), respondentID = "ResponseId", new.format = TRUE)
s2_conjoint_cons <- s2_conjoint_cons[!is.na(s2_conjoint_cons["selected"]),]
s2_conjoint_cons <- s2_conjoint_cons[(s2_conjoint_cons$Finished==1),]

# Relabeling Conjoint Attributes
table(s2_conjoint_cons$`Anti-elitism`)
levels(s2_conjoint_cons$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington insiders")
table(s2_conjoint_cons$`People-centrism`)
levels(s2_conjoint_cons$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "American people", "The people")
table(s2_conjoint_cons$Filler)
levels(s2_conjoint_cons$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")

# Reorder Factor Levels for H2 AMCES
s2_conjoint_cons_b <- s2_conjoint_cons
s2_conjoint_cons_b$`Anti-elitism` <- factor(s2_conjoint_cons_b$`Anti-elitism`, levels=c("Corrupt elite", "Washington insiders", "Out-of-touch bureaucrats", "Control: No anti-elitism statement"))
s2_conjoint_cons_b$`People-centrism` <- factor(s2_conjoint_cons_b$`People-centrism`, levels=c("The people", "American people", "Honest, hardworking citizens", "Control: No people-centrism statement"))




# Rating DV 4: "Have conservative ideology"

# Import "Long" Format Conjoint Data
s2_conjoint_cons_ranks <- read.qualtrics('Prolific_US_Raw.csv', ranks = c("s2_pair1_ideology_1", "s2_pair1_ideology_2", "s2_pair2_ideology_1", "s2_pair2_ideology_2", "s2_pair3_ideology_1", "s2_pair3_ideology_2", "s2_pair4_ideology_1", "s2_pair4_ideology_2", "s2_pair5_ideology_1", "s2_pair5_ideology_2", "s2_pair6_ideology_1", "s2_pair6_ideology_2"), covariates = c("Finished", "Sample"), respondentID = "ResponseId", new.format = TRUE)
s2_conjoint_cons_ranks <- s2_conjoint_cons_ranks[!is.na(s2_conjoint_cons_ranks["selected"]),]
s2_conjoint_cons_ranks <- s2_conjoint_cons_ranks[(s2_conjoint_cons_ranks$Finished==1),]

# Relabeling Conjoint Attributes
table(s2_conjoint_cons_ranks$`Anti-elitism`)
levels(s2_conjoint_cons_ranks$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington insiders")
table(s2_conjoint_cons_ranks$`People-centrism`)
levels(s2_conjoint_cons_ranks$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "American people", "The people")
table(s2_conjoint_cons_ranks$Filler)
levels(s2_conjoint_cons_ranks$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")

# Reorder Factor Levels for H2 AMCES
s2_conjoint_cons_ranks_b <- s2_conjoint_cons_ranks
s2_conjoint_cons_ranks_b$`Anti-elitism` <- factor(s2_conjoint_cons_ranks_b$`Anti-elitism`, levels=c("Corrupt elite", "Washington insiders", "Out-of-touch bureaucrats", "Control: No anti-elitism statement"))
s2_conjoint_cons_ranks_b$`People-centrism` <- factor(s2_conjoint_cons_ranks_b$`People-centrism`, levels=c("The people", "American people", "Honest, hardworking citizens", "Control: No people-centrism statement"))



#########################
# Pooling Samples 1 and 2
#########################

# Combine samples 1 & 2 for People-Centrism Outcome
combined_conjoint_listen = rbind(s1_conjoint_listen, s2_conjoint_listen)
table(combined_conjoint_listen$Partisanship)

# Make Sample Variable a factor
class(combined_conjoint_listen$Sample)
table(combined_conjoint_listen$Sample)
combined_conjoint_listen$Sample <- as.factor(combined_conjoint_listen$Sample)
table(combined_conjoint_listen$Sample)

# Make Partisanship Attribute a Factor
class(combined_conjoint_listen$Partisanship)
combined_conjoint_listen$Partisanship <- as.factor(combined_conjoint_listen$Partisanship)

# For AMCE analyses need to rename attribute names
combined_conjoint_listenb <- combined_conjoint_listen
combined_conjoint_listenb$Antielitism <- combined_conjoint_listenb$`Anti-elitism`
combined_conjoint_listenb$Peoplecentrism <- combined_conjoint_listenb$`People-centrism`


# Combine samples 1 & 2 for People-Centrism Outcome (Ratings)
combined_conjoint_listen_ranks = rbind(s1_conjoint_listen_ranks, s2_conjoint_listen_ranks)
table(combined_conjoint_listen_ranks$Partisanship) # Checking Partisanship label correct

# Make Sample Variable a factor
class(combined_conjoint_listen_ranks$Sample)
table(combined_conjoint_listen_ranks$Sample)
combined_conjoint_listen_ranks$Sample <- as.factor(combined_conjoint_listen_ranks$Sample)
table(combined_conjoint_listen_ranks$Sample)

# Make Partisanship Attribute a Factor
class(combined_conjoint_listen_ranks$Partisanship)
combined_conjoint_listen_ranks$Partisanship <- as.factor(combined_conjoint_listen_ranks$Partisanship)

# For AMCE analyses need to rename attribute names
combined_conjoint_listen_ranksb <- combined_conjoint_listen_ranks
combined_conjoint_listen_ranksb$Antielitism <- combined_conjoint_listen_ranksb$`Anti-elitism`
combined_conjoint_listen_ranksb$Peoplecentrism <- combined_conjoint_listen_ranksb$`People-centrism`


# Combine samples 1 & 2 for Anti-Elitism Outcome
combined_conjoint_crooked = rbind(s1_conjoint_crooked, s2_conjoint_crooked)
table(combined_conjoint_crooked$Partisanship) # Checking Partisanship label correct

# Make Sample Variable a factor
class(combined_conjoint_crooked$Sample)
table(combined_conjoint_crooked$Sample)
combined_conjoint_crooked$Sample <- as.factor(combined_conjoint_crooked$Sample)
table(combined_conjoint_crooked$Sample)

# Make Partisanship Attribute a Factor
class(combined_conjoint_crooked$Partisanship)
combined_conjoint_crooked$Partisanship <- as.factor(combined_conjoint_crooked$Partisanship)

# For AMCE analyses need to rename attribute names
combined_conjoint_crookedb <- combined_conjoint_crooked
combined_conjoint_crookedb$Antielitism <- combined_conjoint_crookedb$`Anti-elitism`
combined_conjoint_crookedb$Peoplecentrism <- combined_conjoint_crookedb$`People-centrism`



# Combine samples 1 & 2 for Anti-Elitism Outcome (Ratings)
combined_conjoint_crooked_ranks = rbind(s1_conjoint_crooked_ranks, s2_conjoint_crooked_ranks)
table(combined_conjoint_crooked_ranks$Partisanship) # Checking Partisanship label correct

# Make Sample Variable a factor
class(combined_conjoint_crooked_ranks$Sample)
table(combined_conjoint_crooked_ranks$Sample)
combined_conjoint_crooked_ranks$Sample <- as.factor(combined_conjoint_crooked_ranks$Sample)
table(combined_conjoint_crooked_ranks$Sample)

# Make Partisanship Attribute a Factor
class(combined_conjoint_crooked_ranks$Partisanship)
combined_conjoint_crooked_ranks$Partisanship <- as.factor(combined_conjoint_crooked_ranks$Partisanship)

# For AMCE analyses need to rename attribute names
combined_conjoint_crooked_ranksb <- combined_conjoint_crooked_ranks
combined_conjoint_crooked_ranksb$Antielitism <- combined_conjoint_crooked_ranksb$`Anti-elitism`
combined_conjoint_crooked_ranksb$Peoplecentrism <- combined_conjoint_crooked_ranksb$`People-centrism`



# Combine samples 1 & 2 for Immigration Outcome
combined_conjoint_immig = rbind(s1_conjoint_immig, s2_conjoint_immig)
table(combined_conjoint_immig$Partisanship) 

# Make Sample Variable a factor
class(combined_conjoint_immig$Sample)
table(combined_conjoint_immig$Sample)
combined_conjoint_immig$Sample <- as.factor(combined_conjoint_immig$Sample)
table(combined_conjoint_immig$Sample)

# Make Partisanship Attribute a Factor
class(combined_conjoint_immig$Partisanship)
combined_conjoint_immig$Partisanship <- as.factor(combined_conjoint_immig$Partisanship)

# For AMCE analyses need to rename attribute names
combined_conjoint_immigb <- combined_conjoint_immig
combined_conjoint_immigb$Antielitism <- combined_conjoint_immigb$`Anti-elitism`
combined_conjoint_immigb$Peoplecentrism <- combined_conjoint_immigb$`People-centrism`

# Combine samples 1 & 2 for Immigration Outcome (Ratings)
combined_conjoint_immig_ranks = rbind(s1_conjoint_immig_ranks, s2_conjoint_immig_ranks)
table(combined_conjoint_immig_ranks$Partisanship) # Checking Partisanship label correct

# Make Sample Variable a factor
class(combined_conjoint_immig_ranks$Sample)
table(combined_conjoint_immig_ranks$Sample)
combined_conjoint_immig_ranks$Sample <- as.factor(combined_conjoint_immig_ranks$Sample)
table(combined_conjoint_immig_ranks$Sample)

# Make Partisanship Attribute a Factor
class(combined_conjoint_immig_ranks$Partisanship)
combined_conjoint_immig_ranks$Partisanship <- as.factor(combined_conjoint_immig_ranks$Partisanship)


# Combine samples 1 & 2 for Conservative Outcome
combined_conjoint_cons = rbind(s1_conjoint_cons, s2_conjoint_cons)
table(combined_conjoint_cons$Partisanship) # Checking Partisanship label correct

# Make Sample Variable a factor
class(combined_conjoint_cons$Sample)
table(combined_conjoint_cons$Sample)
combined_conjoint_cons$Sample <- as.factor(combined_conjoint_cons$Sample)
table(combined_conjoint_cons$Sample)

# Make Partisanship Attribute a Factor
class(combined_conjoint_cons$Partisanship)
combined_conjoint_cons$Partisanship <- as.factor(combined_conjoint_cons$Partisanship)

# For AMCE analyses need to rename attribute names
combined_conjoint_consb <- combined_conjoint_cons
combined_conjoint_consb$Antielitism <- combined_conjoint_consb$`Anti-elitism`
combined_conjoint_consb$Peoplecentrism <- combined_conjoint_consb$`People-centrism`


# Combine samples 1 & 2 for Conservative Outcome (Ratings)
combined_conjoint_cons_ranks = rbind(s1_conjoint_cons_ranks, s2_conjoint_cons_ranks)
table(combined_conjoint_cons_ranks$Partisanship) # Checking Partisanship label correct

# Make Sample Variable a factor
class(combined_conjoint_cons_ranks$Sample)
table(combined_conjoint_cons_ranks$Sample)
combined_conjoint_cons_ranks$Sample <- as.factor(combined_conjoint_cons_ranks$Sample)
table(combined_conjoint_cons_ranks$Sample)

# Make Partisanship Attribute a Factor
class(combined_conjoint_cons_ranks$Partisanship)
combined_conjoint_cons_ranks$Partisanship <- as.factor(combined_conjoint_cons_ranks$Partisanship)

# Alternative Baseline for AMCE Analysis
combined_conjoint_immig_b <- combined_conjoint_immig
combined_conjoint_immig_ranks_b <- combined_conjoint_immig_ranks
combined_conjoint_cons_b <- combined_conjoint_cons
combined_conjoint_cons_ranks_b <- combined_conjoint_cons_ranks

combined_conjoint_immig_b$`Anti-elitism` <- factor(combined_conjoint_immig_b$`Anti-elitism`, levels=c("Corrupt elite", "Washington insiders", "Out-of-touch bureaucrats", "Control: No anti-elitism statement"))
combined_conjoint_immig_ranks_b$`Anti-elitism` <- factor(combined_conjoint_immig_ranks_b$`Anti-elitism`, levels=c("Corrupt elite", "Washington insiders", "Out-of-touch bureaucrats", "Control: No anti-elitism statement"))
combined_conjoint_cons_b$`Anti-elitism` <- factor(combined_conjoint_cons_b$`Anti-elitism`, levels=c("Corrupt elite", "Washington insiders", "Out-of-touch bureaucrats", "Control: No anti-elitism statement"))
combined_conjoint_cons_ranks_b$`Anti-elitism` <- factor(combined_conjoint_cons_ranks_b$`Anti-elitism`, levels=c("Corrupt elite", "Washington insiders", "Out-of-touch bureaucrats", "Control: No anti-elitism statement"))

combined_conjoint_immig_b$`People-centrism` <- factor(combined_conjoint_immig_b$`People-centrism`, levels=c("The people", "American people", "Honest, hardworking citizens", "Control: No people-centrism statement"))
combined_conjoint_immig_ranks_b$`People-centrism` <- factor(combined_conjoint_immig_ranks_b$`People-centrism`, levels=c("The people", "American people", "Honest, hardworking citizens", "Control: No people-centrism statement"))
combined_conjoint_cons_b$`People-centrism` <- factor(combined_conjoint_cons_b$`People-centrism`, levels=c("The people", "American people", "Honest, hardworking citizens", "Control: No people-centrism statement"))
combined_conjoint_cons_ranks_b$`People-centrism` <- factor(combined_conjoint_cons_ranks_b$`People-centrism`, levels=c("The people", "American people", "Honest, hardworking citizens", "Control: No people-centrism statement"))

# For AMCE analyses need to rename attribute names
combined_conjoint_immig_bb <- combined_conjoint_immig_b
combined_conjoint_immig_bb$Antielitism <- combined_conjoint_immig_bb$`Anti-elitism`
combined_conjoint_immig_bb$Peoplecentrism <- combined_conjoint_immig_bb$`People-centrism`

combined_conjoint_cons_bb <- combined_conjoint_cons_b
combined_conjoint_cons_bb$Antielitism <- combined_conjoint_cons_bb$`Anti-elitism`
combined_conjoint_cons_bb$Peoplecentrism <- combined_conjoint_cons_bb$`People-centrism`




#####################################################
# Sample 3: UK Study 
#####################################################

# Note: Sample 3 mirrors the Sample 1 Design
# See information on "Partisan" conjoint attribute in ReadMe file
# Attribute was only displayed to respondents in Sample 2


# DV 1: "Say that politicians should always listen to the people"

# Binary DV 1: "Say that politicians should always listen to the people"

# Import "Long" Format Conjoint Data
s3_conjoint_listen <- read.qualtrics('Prolific_UK_Raw.csv', responses = c("s3_pair1_choice_1","s3_pair2_choice_1","s3_pair3_choice_1","s3_pair4_choice_1","s3_pair5_choice_1", "s3_pair6_choice_1"), covariates = c("Finished"), respondentID = "ResponseId", new.format = TRUE)
s3_conjoint_listen <- s3_conjoint_listen[!is.na(s3_conjoint_listen["selected"]),]
s3_conjoint_listen <- s3_conjoint_listen[(s3_conjoint_listen$Finished==1),]
s3_conjoint_listen$Sample <- "THREE"

# Relabeling Partisanship levels as not shown to respondents (see ReadMe)
table(s3_conjoint_listen$Partisanship)
s3_conjoint_listen$Partisanship = "Not shown"

# Relabeling Conjoint Attributes
table(s3_conjoint_listen$`Anti-elitism`)
levels(s3_conjoint_listen$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Westminster insiders")
table(s3_conjoint_listen$`People-centrism`)
levels(s3_conjoint_listen$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "British people", "The people")
table(s3_conjoint_listen$Filler)
levels(s3_conjoint_listen$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")


# Rating DV 1: "Say that politicians should always listen to the people"

# Import "Long" Format Conjoint Data
s3_conjoint_listen_ranks <- read.qualtrics('Prolific_UK_Raw.csv', ranks = c("s3_pair1_people_1", "s3_pair1_people_2", "s3_pair2_people_1", "s3_pair2_people_2", "s3_pair3_people_1", "s3_pair3_people_2", "s3_pair4_people_1", "s3_pair4_people_2", "s3_pair5_people_1", "s3_pair5_people_2", "s3_pair6_people_1", "s3_pair6_people_2"), covariates = c("Finished"), respondentID = "ResponseId", new.format = TRUE)
s3_conjoint_listen_ranks <- s3_conjoint_listen_ranks[!is.na(s3_conjoint_listen_ranks["selected"]),]
s3_conjoint_listen_ranks <- s3_conjoint_listen_ranks[(s3_conjoint_listen_ranks$Finished==1),]
s3_conjoint_listen_ranks$Sample <- "THREE"

# Relabeling Partisanship levels as not shown to respondents (see ReadMe)
table(s3_conjoint_listen_ranks$Partisanship)
s3_conjoint_listen_ranks$Partisanship = "Not shown"

# Relabeling Conjoint Attributes
table(s3_conjoint_listen_ranks$`Anti-elitism`)
levels(s3_conjoint_listen_ranks$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Westminster insiders")
table(s3_conjoint_listen_ranks$`People-centrism`)
levels(s3_conjoint_listen_ranks$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "British people", "The people")
table(s3_conjoint_listen_ranks$Filler)
levels(s3_conjoint_listen_ranks$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")


# DV 2: "Say that many people in the political class are crooked"

# Binary DV 2: "Say that many people in the political class are crooked"

# Import "Long" Format Conjoint Data
s3_conjoint_crooked <- read.qualtrics('Prolific_UK_Raw.csv', responses = c("s3_pair1_choice_2","s3_pair2_choice_2","s3_pair3_choice_2","s3_pair4_choice_2","s3_pair5_choice_2", "s3_pair6_choice_2"), covariates = c("Finished"),  respondentID = "ResponseId", new.format = TRUE)
s3_conjoint_crooked <- s3_conjoint_crooked[!is.na(s3_conjoint_crooked["selected"]),]
s3_conjoint_crooked <- s3_conjoint_crooked[(s3_conjoint_crooked$Finished==1),]
s3_conjoint_crooked$Sample <- "THREE"

# Relabeling Partisanship levels as not shown to respondents (see ReadMe)
table(s3_conjoint_crooked$Partisanship)
s3_conjoint_crooked$Partisanship = "Not shown"

# Relabeling Conjoint Attributes
table(s3_conjoint_crooked$`Anti-elitism`)
levels(s3_conjoint_crooked$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Westminster insiders")
table(s3_conjoint_crooked$`People-centrism`)
levels(s3_conjoint_crooked$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "British people", "The people")
table(s3_conjoint_crooked$Filler)
levels(s3_conjoint_crooked$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")


# Rating DV 2: "Say that many people in the political class are crooked"

# Import "Long" Format Conjoint Data
s3_conjoint_crooked_ranks <- read.qualtrics('Prolific_UK_Raw.csv', ranks = c("s3_pair1_elite_1", "s3_pair1_elite_2", "s3_pair2_elite_1", "s3_pair2_elite_2", "s3_pair3_elite_1", "s3_pair3_elite_2", "s3_pair4_elite_1", "s3_pair4_elite_2", "s3_pair5_elite_1", "s3_pair5_elite_2", "s3_pair6_elite_1", "s3_pair6_elite_2"), covariates = c("Finished"), respondentID = "ResponseId", new.format = TRUE)
s3_conjoint_crooked_ranks <- s3_conjoint_crooked_ranks[!is.na(s3_conjoint_crooked_ranks["selected"]),]
s3_conjoint_crooked_ranks <- s3_conjoint_crooked_ranks[(s3_conjoint_crooked_ranks$Finished==1),]
s3_conjoint_crooked_ranks$Sample <- "THREE"

# Relabeling Partisanship levels as not shown to respondents (see ReadMe)
table(s3_conjoint_crooked_ranks$Partisanship)
s3_conjoint_crooked_ranks$Partisanship = "Not shown"

# Relabeling Conjoint Attributes
table(s3_conjoint_crooked_ranks$`Anti-elitism`)
levels(s3_conjoint_crooked_ranks$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Westminster insiders")
table(s3_conjoint_crooked_ranks$`People-centrism`)
levels(s3_conjoint_crooked_ranks$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "British people", "The people")
table(s3_conjoint_crooked_ranks$Filler)
levels(s3_conjoint_crooked_ranks$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")


# DV 3: "Say that immigration should be reduced"

# Binary DV 3: "Say that immigration should be reduced"

# Import "Long" Format Conjoint Data
s3_conjoint_immig <- read.qualtrics('Prolific_UK_Raw.csv', responses = c("s3_pair1_choice_3","s3_pair2_choice_3","s3_pair3_choice_3","s3_pair4_choice_3","s3_pair5_choice_3", "s3_pair6_choice_3"), covariates = c("Finished"), respondentID = "ResponseId", new.format = TRUE)
s3_conjoint_immig <- s3_conjoint_immig[!is.na(s3_conjoint_immig["selected"]),]
s3_conjoint_immig <- s3_conjoint_immig[(s3_conjoint_immig$Finished==1),]
s3_conjoint_immig$Sample <- "THREE"

# Relabeling Partisanship levels as not shown to respondents (see ReadMe)
table(s3_conjoint_immig$Partisanship)
s3_conjoint_immig$Partisanship = "Not shown"

# Relabeling Conjoint Attributes
table(s3_conjoint_immig$`Anti-elitism`)
levels(s3_conjoint_immig$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Westminster insiders")
table(s3_conjoint_immig$`People-centrism`)
levels(s3_conjoint_immig$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "British people", "The people")
table(s3_conjoint_immig$Filler)
levels(s3_conjoint_immig$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")


# Reorder Factor Levels for H2 AMCES
s3_conjoint_immig_b <- s3_conjoint_immig
s3_conjoint_immig_b$`Anti-elitism` <- factor(s3_conjoint_immig_b$`Anti-elitism`, levels=c("Corrupt elite", "Westminster insiders", "Out-of-touch bureaucrats", "Control: No anti-elitism statement"))
s3_conjoint_immig_b$`People-centrism` <- factor(s3_conjoint_immig_b$`People-centrism`, levels=c("The people", "British people", "Honest, hardworking citizens", "Control: No people-centrism statement"))




# Rating DV 3: "Say that immigration should be reduced"

# Import "Long" Format Conjoint Data
s3_conjoint_immig_ranks <- read.qualtrics('Prolific_UK_Raw.csv', ranks = c("s3_pair1_immigration_1", "s3_pair1_immigration_2", "s3_pair2_immigration_1", "s3_pair2_immigration_2", "s3_pair3_immigration_1", "s3_pair3_immigration_2", "s3_pair4_immigration_1", "s3_pair4_immigration_2", "s3_pair5_immigration_1", "s3_pair5_immigration_2", "s3_pair6_immigration_1", "s3_pair6_immigration_2"), covariates = c("Finished"), respondentID = "ResponseId", new.format = TRUE)
s3_conjoint_immig_ranks <- s3_conjoint_immig_ranks[!is.na(s3_conjoint_immig_ranks["selected"]),]
s3_conjoint_immig_ranks <- s3_conjoint_immig_ranks[(s3_conjoint_immig_ranks$Finished==1),]
s3_conjoint_immig_ranks$Sample <- "THREE"

# Relabeling Partisanship levels as not shown to respondents (see ReadMe)
table(s3_conjoint_immig_ranks$Partisanship)
s3_conjoint_immig_ranks$Partisanship = "Not shown"

# Relabeling Conjoint Attributes
table(s3_conjoint_immig_ranks$`Anti-elitism`)
levels(s3_conjoint_immig_ranks$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Westminster insiders")
table(s3_conjoint_immig_ranks$`People-centrism`)
levels(s3_conjoint_immig_ranks$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "British people", "The people")
table(s3_conjoint_immig_ranks$Filler)
levels(s3_conjoint_immig_ranks$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")

# Reorder Factor Levels for H2 AMCES
s3_conjoint_immig_ranks_b <- s3_conjoint_immig_ranks
s3_conjoint_immig_ranks_b$`Anti-elitism` <- factor(s3_conjoint_immig_ranks_b$`Anti-elitism`, levels=c("Corrupt elite", "Westminster insiders", "Out-of-touch bureaucrats", "Control: No anti-elitism statement"))
s3_conjoint_immig_ranks_b$`People-centrism` <- factor(s3_conjoint_immig_ranks_b$`People-centrism`, levels=c("The people", "British people", "Honest, hardworking citizens", "Control: No people-centrism statement"))



# DV 4: "Have conservative ideology"

# Binary DV 4: "Have conservative ideology"

# Import "Long" Format Conjoint Data
s3_conjoint_cons <- read.qualtrics('Prolific_UK_Raw.csv', responses = c("s3_pair1_choice_4","s3_pair2_choice_4","s3_pair3_choice_4","s3_pair4_choice_4","s3_pair5_choice_4", "s3_pair6_choice_4"), covariates = c("Finished"), respondentID = "ResponseId", new.format = TRUE)
s3_conjoint_cons <- s3_conjoint_cons[!is.na(s3_conjoint_cons["selected"]),]
s3_conjoint_cons <- s3_conjoint_cons[(s3_conjoint_cons$Finished==1),]
s3_conjoint_cons$Sample <- "THREE"

# Relabeling Partisanship levels as not shown to respondents (see ReadMe)
table(s3_conjoint_cons$Partisanship)
s3_conjoint_cons$Partisanship = "Not shown"

# Relabeling Conjoint Attributes
table(s3_conjoint_cons$`Anti-elitism`)
levels(s3_conjoint_cons$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Westminster insiders")
table(s3_conjoint_cons$`People-centrism`)
levels(s3_conjoint_cons$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "British people", "The people")
table(s3_conjoint_cons$Filler)
levels(s3_conjoint_cons$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")

# Reorder Factor Levels for H2 AMCES
s3_conjoint_cons_b <- s3_conjoint_cons
s3_conjoint_cons_b$`Anti-elitism` <- factor(s3_conjoint_cons_b$`Anti-elitism`, levels=c("Corrupt elite", "Westminster insiders", "Out-of-touch bureaucrats", "Control: No anti-elitism statement"))
s3_conjoint_cons_b$`People-centrism` <- factor(s3_conjoint_cons_b$`People-centrism`, levels=c("The people", "British people", "Honest, hardworking citizens", "Control: No people-centrism statement"))


# Rating DV 4: "Have conservative ideology"

# Note: Question wording is different here
# Asks about left-right instead of liberal-conservative

# Import "Long" Format Conjoint Data
s3_conjoint_cons_ranks <- read.qualtrics('Prolific_UK_Raw.csv', ranks = c("s3_pair1_ideology_1", "s3_pair1_ideology_2", "s3_pair2_ideology_1", "s3_pair2_ideology_2", "s3_pair3_ideology_1", "s3_pair3_ideology_2", "s3_pair4_ideology_1", "s3_pair4_ideology_2", "s3_pair5_ideology_1", "s3_pair5_ideology_2", "s3_pair6_ideology_1", "s3_pair6_ideology_2"), covariates = c("Finished"), respondentID = "ResponseId", new.format = TRUE)
s3_conjoint_cons_ranks <- s3_conjoint_cons_ranks[!is.na(s3_conjoint_cons_ranks["selected"]),]
s3_conjoint_cons_ranks <- s3_conjoint_cons_ranks[(s3_conjoint_cons_ranks$Finished==1),]
s3_conjoint_cons_ranks$Sample <- "THREE"

# Relabeling Partisanship levels as not shown to respondents (see ReadMe)
table(s3_conjoint_cons_ranks$Partisanship)
s3_conjoint_cons_ranks$Partisanship = "Not shown"

# Relabeling Conjoint Attributes
table(s3_conjoint_cons_ranks$`Anti-elitism`)
levels(s3_conjoint_cons_ranks$`Anti-elitism`) <- c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Westminster insiders")
table(s3_conjoint_cons_ranks$`People-centrism`)
levels(s3_conjoint_cons_ranks$`People-centrism`) <- c("Control: No people-centrism statement","Honest, hardworking citizens", "British people", "The people")
table(s3_conjoint_cons_ranks$Filler)
levels(s3_conjoint_cons_ranks$Filler) <- c("Children are the future", "Bread-and-butter issues", "Overlooked industries", "Semiconductor manufacturing")

# Reorder Factor Levels for H2 AMCES
s3_conjoint_cons_ranks_b <- s3_conjoint_cons_ranks
s3_conjoint_cons_ranks_b$`Anti-elitism` <- factor(s3_conjoint_cons_ranks_b$`Anti-elitism`, levels=c("Corrupt elite", "Westminster insiders", "Out-of-touch bureaucrats", "Control: No anti-elitism statement"))
s3_conjoint_cons_ranks_b$`People-centrism` <- factor(s3_conjoint_cons_ranks_b$`People-centrism`, levels=c("The people", "British people", "Honest, hardworking citizens", "Control: No people-centrism statement"))



#####################################################
# Pooling Samples 1 and 3 for RQ4 Analyses
#####################################################

# Combine samples 1 & 3 for Listen Outcome
s1s3_combined_conjoint_listen = rbind(s1_conjoint_listen, s3_conjoint_listen)
s1s3_combined_conjoint_listen_ranks = rbind(s1_conjoint_listen_ranks, s3_conjoint_listen_ranks)

# Make Sample Variable a factor
class(s1s3_combined_conjoint_listen$Sample)
table(s1s3_combined_conjoint_listen$Sample)
s1s3_combined_conjoint_listen$Sample <- as.factor(s1s3_combined_conjoint_listen$Sample)
table(s1s3_combined_conjoint_listen$Sample)

# Make Sample Variable a factor
class(s1s3_combined_conjoint_listen_ranks$Sample)
table(s1s3_combined_conjoint_listen_ranks$Sample)
s1s3_combined_conjoint_listen_ranks$Sample <- as.factor(s1s3_combined_conjoint_listen_ranks$Sample)
table(s1s3_combined_conjoint_listen_ranks$Sample)

# Make Levels Comparable & Reorder Levels
table(s1s3_combined_conjoint_listen$`Anti-elitism`)
s1s3_combined_conjoint_listen <- s1s3_combined_conjoint_listen %>%
  mutate(`Anti-elitism`= recode(`Anti-elitism`, "c('Westminster insiders', 'Washington insiders')='Washington/Westminster insiders'"))

s1s3_combined_conjoint_listen$`Anti-elitism` <- factor(s1s3_combined_conjoint_listen$`Anti-elitism`, levels=c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington/Westminster insiders"))

table(s1s3_combined_conjoint_listen$`People-centrism`)
s1s3_combined_conjoint_listen <- s1s3_combined_conjoint_listen %>%
  mutate(`People-centrism`= recode(`People-centrism`, "c('American people', 'British people')='American/British people'"))
s1s3_combined_conjoint_listen$`People-centrism` <- factor(s1s3_combined_conjoint_listen$`People-centrism`, levels=c("Control: No people-centrism statement", "Honest, hardworking citizens", "American/British people", "The people"))


table(s1s3_combined_conjoint_listen_ranks$`Anti-elitism`)
s1s3_combined_conjoint_listen_ranks <- s1s3_combined_conjoint_listen_ranks %>%
  mutate(`Anti-elitism`= recode(`Anti-elitism`, "c('Westminster insiders', 'Washington insiders')='Washington/Westminster insiders'"))

s1s3_combined_conjoint_listen_ranks$`Anti-elitism` <- factor(s1s3_combined_conjoint_listen_ranks$`Anti-elitism`, levels=c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington/Westminster insiders"))

table(s1s3_combined_conjoint_listen_ranks$`People-centrism`)
s1s3_combined_conjoint_listen_ranks <- s1s3_combined_conjoint_listen_ranks %>%
  mutate(`People-centrism`= recode(`People-centrism`, "c('American people', 'British people')='American/British people'"))
s1s3_combined_conjoint_listen_ranks$`People-centrism` <- factor(s1s3_combined_conjoint_listen_ranks$`People-centrism`, levels=c("Control: No people-centrism statement", "Honest, hardworking citizens", "American/British people", "The people"))


# Combine samples 1 & 3 for Crooked Outcome
s1s3_combined_conjoint_crooked = rbind(s1_conjoint_crooked, s3_conjoint_crooked)
s1s3_combined_conjoint_crooked_ranks = rbind(s1_conjoint_crooked_ranks, s3_conjoint_crooked_ranks)


# Make Sample Variable a factor
class(s1s3_combined_conjoint_crooked$Sample)
table(s1s3_combined_conjoint_crooked$Sample)
s1s3_combined_conjoint_crooked$Sample <- as.factor(s1s3_combined_conjoint_crooked$Sample)
table(s1s3_combined_conjoint_crooked$Sample)

# Make Sample Variable a factor
class(s1s3_combined_conjoint_crooked_ranks$Sample)
table(s1s3_combined_conjoint_crooked_ranks$Sample)
s1s3_combined_conjoint_crooked_ranks$Sample <- as.factor(s1s3_combined_conjoint_crooked_ranks$Sample)
table(s1s3_combined_conjoint_crooked_ranks$Sample)


# Make Levels Comparable & Reorder Levels
table(s1s3_combined_conjoint_crooked$`Anti-elitism`)
s1s3_combined_conjoint_crooked <- s1s3_combined_conjoint_crooked %>%
  mutate(`Anti-elitism`= recode(`Anti-elitism`, "c('Westminster insiders', 'Washington insiders')='Washington/Westminster insiders'"))

s1s3_combined_conjoint_crooked$`Anti-elitism` <- factor(s1s3_combined_conjoint_crooked$`Anti-elitism`, levels=c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington/Westminster insiders"))

table(s1s3_combined_conjoint_crooked$`People-centrism`)
s1s3_combined_conjoint_crooked <- s1s3_combined_conjoint_crooked %>%
  mutate(`People-centrism`= recode(`People-centrism`, "c('American people', 'British people')='American/British people'"))
s1s3_combined_conjoint_crooked$`People-centrism` <- factor(s1s3_combined_conjoint_crooked$`People-centrism`, levels=c("Control: No people-centrism statement", "Honest, hardworking citizens", "American/British people", "The people"))

table(s1s3_combined_conjoint_crooked_ranks$`Anti-elitism`)
s1s3_combined_conjoint_crooked_ranks <- s1s3_combined_conjoint_crooked_ranks %>%
  mutate(`Anti-elitism`= recode(`Anti-elitism`, "c('Westminster insiders', 'Washington insiders')='Washington/Westminster insiders'"))

s1s3_combined_conjoint_crooked_ranks$`Anti-elitism` <- factor(s1s3_combined_conjoint_crooked_ranks$`Anti-elitism`, levels=c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington/Westminster insiders"))

table(s1s3_combined_conjoint_crooked_ranks$`People-centrism`)
s1s3_combined_conjoint_crooked_ranks <- s1s3_combined_conjoint_crooked_ranks %>%
  mutate(`People-centrism`= recode(`People-centrism`, "c('American people', 'British people')='American/British people'"))
s1s3_combined_conjoint_crooked_ranks$`People-centrism` <- factor(s1s3_combined_conjoint_crooked_ranks$`People-centrism`, levels=c("Control: No people-centrism statement", "Honest, hardworking citizens", "American/British people", "The people"))


# Combine samples 1 & 3 for Immigration Outcome
s1s3_combined_conjoint_immig = rbind(s1_conjoint_immig, s3_conjoint_immig)
s1s3_combined_conjoint_immig_ranks = rbind(s1_conjoint_immig_ranks, s3_conjoint_immig_ranks)

# Make Sample Variable a factor
class(s1s3_combined_conjoint_immig$Sample)
table(s1s3_combined_conjoint_immig$Sample)
s1s3_combined_conjoint_immig$Sample <- as.factor(s1s3_combined_conjoint_immig$Sample)
table(s1s3_combined_conjoint_immig$Sample)

# Make Sample Variable a factor
class(s1s3_combined_conjoint_immig_ranks$Sample)
table(s1s3_combined_conjoint_immig_ranks$Sample)
s1s3_combined_conjoint_immig_ranks$Sample <- as.factor(s1s3_combined_conjoint_immig_ranks$Sample)
table(s1s3_combined_conjoint_immig_ranks$Sample)

# Make Levels Comparable & Reorder Levels
table(s1s3_combined_conjoint_immig$`Anti-elitism`)
s1s3_combined_conjoint_immig <- s1s3_combined_conjoint_immig %>%
  mutate(`Anti-elitism`= recode(`Anti-elitism`, "c('Westminster insiders', 'Washington insiders')='Washington/Westminster insiders'"))

s1s3_combined_conjoint_immig$`Anti-elitism` <- factor(s1s3_combined_conjoint_immig$`Anti-elitism`, levels=c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington/Westminster insiders"))

table(s1s3_combined_conjoint_immig$`People-centrism`)
s1s3_combined_conjoint_immig <- s1s3_combined_conjoint_immig %>%
  mutate(`People-centrism`= recode(`People-centrism`, "c('American people', 'British people')='American/British people'"))
s1s3_combined_conjoint_immig$`People-centrism` <- factor(s1s3_combined_conjoint_immig$`People-centrism`, levels=c("Control: No people-centrism statement", "Honest, hardworking citizens", "American/British people", "The people"))

table(s1s3_combined_conjoint_immig_ranks$`Anti-elitism`)
s1s3_combined_conjoint_immig_ranks <- s1s3_combined_conjoint_immig_ranks %>%
  mutate(`Anti-elitism`= recode(`Anti-elitism`, "c('Westminster insiders', 'Washington insiders')='Washington/Westminster insiders'"))

s1s3_combined_conjoint_immig_ranks$`Anti-elitism` <- factor(s1s3_combined_conjoint_immig_ranks$`Anti-elitism`, levels=c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington/Westminster insiders"))

table(s1s3_combined_conjoint_immig_ranks$`People-centrism`)
s1s3_combined_conjoint_immig_ranks <- s1s3_combined_conjoint_immig_ranks %>%
  mutate(`People-centrism`= recode(`People-centrism`, "c('American people', 'British people')='American/British people'"))
s1s3_combined_conjoint_immig_ranks$`People-centrism` <- factor(s1s3_combined_conjoint_immig_ranks$`People-centrism`, levels=c("Control: No people-centrism statement", "Honest, hardworking citizens", "American/British people", "The people"))


# Combine samples 1 & 3 for Conservative Outcomes
# Note: Question wording differs for rating outcomes
s1s3_combined_conjoint_cons = rbind(s1_conjoint_cons, s3_conjoint_cons)
s1s3_combined_conjoint_cons_ranks = rbind(s1_conjoint_cons_ranks, s3_conjoint_cons_ranks)

# Make Sample Variable a factor
class(s1s3_combined_conjoint_cons$Sample)
table(s1s3_combined_conjoint_cons$Sample)
s1s3_combined_conjoint_cons$Sample <- as.factor(s1s3_combined_conjoint_cons$Sample)
table(s1s3_combined_conjoint_cons$Sample)

# Make Sample Variable a factor
class(s1s3_combined_conjoint_cons_ranks$Sample)
table(s1s3_combined_conjoint_cons_ranks$Sample)
s1s3_combined_conjoint_cons_ranks$Sample <- as.factor(s1s3_combined_conjoint_cons_ranks$Sample)
table(s1s3_combined_conjoint_cons_ranks$Sample)

# Make Levels Comparable & Reorder Levels
table(s1s3_combined_conjoint_cons$`Anti-elitism`)
s1s3_combined_conjoint_cons <- s1s3_combined_conjoint_cons %>%
  mutate(`Anti-elitism`= recode(`Anti-elitism`, "c('Westminster insiders', 'Washington insiders')='Washington/Westminster insiders'"))

s1s3_combined_conjoint_cons$`Anti-elitism` <- factor(s1s3_combined_conjoint_cons$`Anti-elitism`, levels=c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington/Westminster insiders"))

table(s1s3_combined_conjoint_cons$`People-centrism`)
s1s3_combined_conjoint_cons <- s1s3_combined_conjoint_cons %>%
  mutate(`People-centrism`= recode(`People-centrism`, "c('American people', 'British people')='American/British people'"))
s1s3_combined_conjoint_cons$`People-centrism` <- factor(s1s3_combined_conjoint_cons$`People-centrism`, levels=c("Control: No people-centrism statement", "Honest, hardworking citizens", "American/British people", "The people"))


table(s1s3_combined_conjoint_cons_ranks$`Anti-elitism`)
s1s3_combined_conjoint_cons_ranks <- s1s3_combined_conjoint_cons_ranks %>%
  mutate(`Anti-elitism`= recode(`Anti-elitism`, "c('Westminster insiders', 'Washington insiders')='Washington/Westminster insiders'"))

s1s3_combined_conjoint_cons_ranks$`Anti-elitism` <- factor(s1s3_combined_conjoint_cons_ranks$`Anti-elitism`, levels=c("Control: No anti-elitism statement", "Out-of-touch bureaucrats", "Corrupt elite", "Washington/Westminster insiders"))

table(s1s3_combined_conjoint_cons_ranks$`People-centrism`)
s1s3_combined_conjoint_cons_ranks <- s1s3_combined_conjoint_cons_ranks %>%
  mutate(`People-centrism`= recode(`People-centrism`, "c('American people', 'British people')='American/British people'"))
s1s3_combined_conjoint_cons_ranks$`People-centrism` <- factor(s1s3_combined_conjoint_cons_ranks$`People-centrism`, levels=c("Control: No people-centrism statement", "Honest, hardworking citizens", "American/British people", "The people"))







